package com.haoxiaozhang.hxz_app.activity;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toolbar;

import com.haoxiaozhang.hxz_app.R;

import androidx.appcompat.app.AppCompatActivity;

public class BaseActivity extends AppCompatActivity {

    protected ProgressDialog progressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawableResource(R.color.activityBg);


        //初始化加载中进度
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("加载中...");

    }

    protected void setBackToolBar(String title){

        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.setNavigationIcon(R.mipmap.back);
        TextView titleView = toolbar.findViewById(R.id.title_name);
        titleView.setText(title);

        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

    }

    protected void setUpToolbar(){

        Button caidanButton = findViewById(R.id.button_caidan);
        Button xiaoxiButton = findViewById(R.id.button_xiaoxi);

        //菜单点击
        caidanButton.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Log.d("TAG","菜单点击处理");
           }
        });

       //消息点击
        xiaoxiButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("TAG","消息点击处理");
            }
        });

    }


    public void startLoadingProgress() {
        progressDialog.show();
    }

    public void stopLoadingProgress() {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
    }
}


